home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / upstart-compat-sysv.preinst < prev    next >
Text File  |  2008-09-29  |  2KB  |  78 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Prepare to remove a no-longer used conffile
  19. prep_rm_conffile()
  20. {
  21.     CONFFILE="$1"
  22.  
  23.     if [ -e "$CONFFILE" ]; then
  24.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  25.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  26.         if [ "$md5sum" != "$old_md5sum" ]; then
  27.             echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  28.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  29.     else
  30.         mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
  31.     fi
  32.     fi
  33. }
  34.  
  35.  
  36. # Replace the documentation directory with a symlink to the common one.
  37. replace_doc_dir()
  38. {
  39.     DOCDIR="/usr/share/doc/upstart-compat-sysv"
  40.  
  41.     if [ -d "$DOCDIR" ] && [ ! -L "$DOCDIR" ]; then
  42.     rm -rf "$DOCDIR"
  43.     ln -sf "upstart" "$DOCDIR"
  44.     fi
  45. }
  46.  
  47. # Prepare to remove obsolete jobs
  48. prep_rm_obsolete_jobs()
  49. {
  50.     prep_rm_conffile /etc/event.d/rc0-halt
  51.     prep_rm_conffile /etc/event.d/rc0-poweroff
  52. }
  53.  
  54.  
  55. case "$1" in
  56.     install)
  57.         ;;
  58.  
  59.     upgrade)
  60.     # Upgrade from edgy
  61.     if dpkg --compare-versions "$2" lt "0.3.5-1"; then
  62.         replace_doc_dir
  63.         prep_rm_obsolete_jobs
  64.     fi
  65.     ;;
  66.  
  67.     abort-upgrade)
  68.     ;;
  69.  
  70.     *)
  71.     echo "$0 called with unknown argument \`$1'" 1>&2
  72.     exit 1
  73.     ;;
  74. esac
  75.  
  76.  
  77. exit 0
  78.